export const routeList:Array<RouteItem> = [
  {
    isHideNav: false,
    isHideMenu: true,
    name: "首页",
    title: "首页",
    subtitle: "首页副标题",
    path: "/",
    children: []
  },
  {
    isHideNav: false,
    isHideMenu: false,
    name: "电影",
    title: "电影",
    subtitle: "电影副标题",
    path: "/movice/list",
    children: []
  },
  {
    isHideNav: false,
    isHideMenu: false,
    name: "资源",
    title: "资源",
    subtitle: "资源副标题",
    path: "/resource/list",
    children: []
  }
];

/**
 * 根据path找到当前激活的导航index
 */
export function findPathIndex(path:string, routes?: Array<RouteItem>):number|undefined {
  if (!routes) routes = routeList;
  for (let index = 0; index < routes.length; index++) {
    const route = routes[index];
    if (route.path === path) return index;
    if (route.children.length) {
      const resultIndex:number|undefined = findPathIndex(path, route.children);
      if (resultIndex!==undefined) return resultIndex;
    }
  }
}